/**
 业主详情页面
 **/
(function (vc) {
    vc.extends({
        data: {
            adminOwnerDetailInfo: {
                viewOwnerFlag: '',
                ownerId: "",
                memberId: '',
                name: "",
                age: "",
                sex: "",
                userName: "",
                remark: "",
                idCard: "",
                link: "",
                ownerPhoto: "/img/noPhoto.jpg",
                ownerAttrDtos: [],
                faceUrl: '',
                _currentTab: 'aRoomDetailRoom',
                personType:'',
                personTypeName:'',
                personRole:'',
                personRoleName:'',
                concactLink:'',
                concactPerson:'',
                communityName:'',
                needBack: false
            }
        },
        _initMethod: function () {
            $that.adminOwnerDetailInfo.ownerId = vc.getParam('ownerId');
            $that.adminOwnerDetailInfo.needBack = vc.getParam('needBack');
            if (!vc.notNull($that.adminOwnerDetailInfo.ownerId)) {
                return;
            }
            let _currentTab = vc.getParam('currentTab');
            if (_currentTab) {
                $that.adminOwnerDetailInfo._currentTab = _currentTab;
            }
            $that._loadAdminOwnerInfo();
            $that.changeTab($that.adminOwnerDetailInfo._currentTab);
        },
        _initEvent: function () {
            vc.on('adminOwnerDetail', 'listOwnerData', function (_info) {
                $that._loadAdminOwnerInfo();
                $that.changeTab($that.adminOwnerDetailInfo._currentTab);
            });
        },
        methods: {
            _loadAdminOwnerInfo: function () {
                let param = {
                    params: {
                        ownerId: $that.adminOwnerDetailInfo.ownerId,
                        page: 1,
                        row: 1,
                        ownerTypeCd: '1001'
                    }
                }
                //发送get请求
                vc.http.apiGet('/owner.queryAdminOwners',
                    param,
                    function (json, res) {
                        let _json = JSON.parse(json);
                        vc.copyObject(_json.data[0], $that.adminOwnerDetailInfo);
                        $that.adminOwnerDetailInfo.ownerAttrDtos = _json.owners[0].ownerAttrDtos;
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            changeTab: function (_tab) {
                $that.adminOwnerDetailInfo._currentTab = _tab;
                vc.emit(_tab, 'switch', {
                    ownerId: $that.adminOwnerDetailInfo.ownerId,
                    ownerName: $that.adminOwnerDetailInfo.name,
                    link: $that.adminOwnerDetailInfo.link,
                })
            },
            errorLoadImg: function () {
                $that.adminOwnerDetailInfo.ownerPhoto = "/img/noPhoto.jpg";
            },
        }
    });
})(window.vc);